﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TestApp
{
    public partial class cargardatos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ServRefWS.serviciointegradorSoapClient sr = new ServRefWS.serviciointegradorSoapClient();
            List<ServRefWS.datosmini> dm = sr.cargardatosmini();
            List<ServRefWS.datosrestric> dr = sr.cargardatosrestric();
            foreach (ServRefWS.datosmini dm1 in dm)
            {
                if (dm1.varobj == 1)
                {
                    TextBox1.Text = dm1.valorobj.ToString();
                    TextBox9.Text = dm1.cotainf.ToString();
                    TextBox11.Text = (dm1.cotasup != null) ? dm1.cotasup.ToString() : "infinito";
                }
                else
                {
                    TextBox2.Text = dm1.valorobj.ToString();
                    TextBox10.Text = dm1.cotainf.ToString();
                    TextBox12.Text = (dm1.cotasup != null) ? dm1.cotasup.ToString() : "infinito";
                }
            }
            #region
            foreach (ServRefWS.datosrestric dr1 in dr)
            {
                if (dr1.idrestric == 1)
                {
                    TextBox3.Text = dr1.valorobj1.ToString();
                    TextBox4.Text = dr1.valorobj2.ToString();
                    TextBox5.Text = dr1.valorrestric.ToString();
                }
                else
                {
                    TextBox6.Text = dr1.valorobj1.ToString();
                    TextBox7.Text = dr1.valorobj2.ToString();
                    TextBox8.Text = dr1.valorrestric.ToString();
                }
            }
#endregion
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            ServRefWS.serviciointegradorSoapClient sr = new ServRefWS.serviciointegradorSoapClient();
            #region
            ServRefWS.ArrayOfDatosmini dm = new ServRefWS.ArrayOfDatosmini();
            ServRefWS.datosmini dm1 = new ServRefWS.datosmini();
            dm1.valorobj = float.Parse(TextBox1.Text);
            dm1.varobj = 1;dm1.cotainf = float.Parse(TextBox9.Text);
            dm1.cotasup = (TextBox11.Text != "infinito") ? (float?)float.Parse(TextBox11.Text) : null;
            dm.Add(dm1);
            ServRefWS.datosmini dm2 = new ServRefWS.datosmini();
            dm2.valorobj = float.Parse(TextBox2.Text);
            dm2.varobj = 2; dm1.cotainf = float.Parse(TextBox10.Text);
            dm2.cotasup = (TextBox12.Text != "infinito") ? (float?)float.Parse(TextBox12.Text) : null;
            dm.Add(dm2);
            #endregion
            ServRefWS.ArrayOfDatosrestric dr = new ServRefWS.ArrayOfDatosrestric();
            ServRefWS.datosrestric dr0 = new ServRefWS.datosrestric();
            dr0.idrestric = 1; dr0.valorrestric = float.Parse(TextBox5.Text);
            dr0.valorobj1 = float.Parse(TextBox3.Text);
            dr0.valorobj2 = float.Parse(TextBox4.Text);
            dr.Add(dr0);
            ServRefWS.datosrestric dr1 = new ServRefWS.datosrestric();
            dr1.idrestric = 2; dr1.valorrestric = float.Parse(TextBox8.Text);
            dr1.valorobj1 = float.Parse(TextBox6.Text);
            dr1.valorobj2 = float.Parse(TextBox7.Text);
            dr.Add(dr1);
            Label11.Text=sr.callindo(dm,dr);
        }
    }
}